-- Orewood Reborn Compatibility Registry. I would like to thank desvox for making the orewood mod this one originated from.

-- Only mods that add a single item to renew are here:
-- quartz................8
-- blox................124

if(minetest.get_modpath("quartz")) ~= nil then
--craft
minetest.register_craft({
	output = '"orewood:quartzwood_fake"',
	recipe = {
		{'quartz:block', 'quartz:block','quartz:block'},
		{'quartz:block', 'group:orewood_quartz','quartz:block'},
		{'quartz:block', 'quartz:block','quartz:block'},
	}
})

minetest.register_craft({
	output = '"orewood:quartzwood"',
	recipe = {
		{'group:stone', 'group:wood','group:stone'},
		{'group:wood', 'quartz:block','group:wood'},
		{'group:stone', 'group:wood','group:stone'},
	}
})
--wooden nodes
minetest.register_node(":orewood:quartzwood", {
	description = "Quartzwood",
	tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png^quartz_ore.png"},
	paramtype2 = "facedir",
	is_ground_content = false,
	groups = {orewood_quartz=1,orew_quartz=1,tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
	sounds = default.node_sound_wood_defaults(),

	on_place = minetest.rotate_node
})
--fake nodes
minetest.register_node(":orewood:quartzwood_fake", {
	description = "Fake Quartzwood",
	tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_tree.png^quartz_ore.png"},
	paramtype2 = "facedir",
	is_ground_content = false,
	groups = {orewood_quartz=1,orew_fake=1,tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
	sounds = default.node_sound_wood_defaults(),

	on_place = minetest.rotate_node
})
--papy nodes
minetest.register_node(":orewood:quartzpapy", {
	description = "Quartzpapy",
	drop = "quartz:quartz_crystal_piece",
	drawtype = "plantlike",
	stack_max = 999,
	tiles = {"quartz_block.png^orewood_cover_mp.png^[makealpha:255,0,255"},
	inventory_image = "quartz_block.png^orewood_cover_mp.png^[makealpha:255,0,255",
	wield_image = "quartz_block.png^orewood_cover_mp.png^[makealpha:255,0,255",
	paramtype = "light",
	walkable = false,
	is_ground_content = true,
	selection_box = {
		type = "fixed",
		fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
	},
	groups = {snappy=3,flammable=2},
	sounds = default.node_sound_leaves_defaults(),

	after_dig_node = function(pos, node, metadata, digger)
		default.dig_up(pos, node, digger)
	end,
})
--ABMs srpout
minetest.register_abm({
	nodenames = {"orewood:quartzwood"},
	neighbors = {"default:water_source"},
	interval = 40,
	chance = 10,
	action = function(pos, node)
	local height = 0
	while node.name == "orewood:quartzwood" and height < 4 do
		height = height+1
		pos.y = pos.y+1
		node = minetest.get_node(pos)
	end
	if height == 4
	or node.name ~= "air" then
		return
	end
	minetest.set_node(pos, {name="orewood:quartzpapy"})
	end,
})
--ABMs grow
minetest.register_abm({
	nodenames = {"orewood:quartzpapy"},
	neighbors = {"orewood:quartzwood"},
	interval = 50,
	chance = 20,
	action = function(pos, node)
	pos.y = pos.y-1
	local name = minetest.get_node(pos).name
	if name ~= "orewood:quartzwood"
	and name ~= "orewood:quartzwood" then
		return
	end
	if not minetest.find_node_near(pos, 3, {"group:water"}) then
		return
	end
	pos.y = pos.y+1
	local height = 0
	while node.name == "orewood:quartzpapy" and height < 4 do
		height = height+1
		pos.y = pos.y+1
		node = minetest.get_node(pos)
	end
	if height == 4
	or node.name ~= "air" then
		return
	end
	minetest.set_node(pos, {name="orewood:quartzpapy"})
	return true
end,
})
end

if(minetest.get_modpath("blox")) ~= nil then
--craft
minetest.register_craft({
	output = '"orewood:glowdustwood_fake"',
	recipe = {
		{'blox:glowstone', 'blox:glowstone','blox:glowstone'},
		{'blox:glowstone', 'group:orewood_blox','blox:glowstone'},
		{'blox:glowstone', 'blox:glowstone','blox:glowstone'},
	}
})

minetest.register_craft({
	output = '"orewood:glowdustwood"',
	recipe = {
		{'group:stone', 'group:wood','group:stone'},
		{'group:wood', 'blox:glowstone','group:wood'},
		{'group:stone', 'group:wood','group:stone'},
	}
})
--wooden nodes
minetest.register_node(":orewood:glowdustwood", {
	description = "Glowdustwood",
	tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png^blox_glowore.png"},
	paramtype2 = "facedir",
	is_ground_content = false,
	groups = {orewood_blox=1,orew_glowdust=1,tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
	sounds = default.node_sound_wood_defaults(),

	on_place = minetest.rotate_node
})
--fake nodes
minetest.register_node(":orewood:glowdustwood_fake", {
	description = "Fake Glowdustwood",
	tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_tree.png^blox_glowore.png"},
	paramtype2 = "facedir",
	is_ground_content = false,
	groups = {orewood_blox=1,orew_fake=1,tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
	sounds = default.node_sound_wood_defaults(),

	on_place = minetest.rotate_node
})
--papy nodes
minetest.register_node(":orewood:glowdustpapy", {
	description = "Glowdustpapy",
	drop = "blox:glowdust",
	drawtype = "plantlike",
	stack_max = 999,
	tiles = {"blox_glowstone.png^orewood_cover_mp.png^[makealpha:255,0,255"},
	inventory_image = "blox_glowstone.png^orewood_cover_mp.png^[makealpha:255,0,255",
	wield_image = "blox_glowstone.png^orewood_cover_mp.png^[makealpha:255,0,255",
	paramtype = "light",
	walkable = false,
	is_ground_content = true,
	selection_box = {
		type = "fixed",
		fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
	},
	groups = {snappy=3,flammable=2},
	sounds = default.node_sound_leaves_defaults(),

	after_dig_node = function(pos, node, metadata, digger)
		default.dig_up(pos, node, digger)
	end,
})
--ABMs srpout
minetest.register_abm({
	nodenames = {"orewood:glowdustwood"},
	neighbors = {"default:water_source"},
	interval = 40,
	chance = 10,
	action = function(pos, node)
	local height = 0
	while node.name == "orewood:glowdustwood" and height < 4 do
		height = height+1
		pos.y = pos.y+1
		node = minetest.get_node(pos)
	end
	if height == 4
	or node.name ~= "air" then
		return
	end
	minetest.set_node(pos, {name="orewood:glowdustpapy"})
	end,
})
--grow
minetest.register_abm({
	nodenames = {"orewood:glowdustpapy"},
	neighbors = {"orewood:glowdustwood"},
	interval = 50,
	chance = 20,
	action = function(pos, node)
	pos.y = pos.y-1
	local name = minetest.get_node(pos).name
	if name ~= "orewood:glowdustwood"
	and name ~= "orewood:glowdustwood" then
		return
	end
	if not minetest.find_node_near(pos, 3, {"group:water"}) then
		return
	end
	pos.y = pos.y+1
	local height = 0
	while node.name == "orewood:glowdustpapy" and height < 4 do
		height = height+1
		pos.y = pos.y+1
		node = minetest.get_node(pos)
	end
	if height == 4
	or node.name ~= "air" then
		return
	end
	minetest.set_node(pos, {name="orewood:glowdustpapy"})
	return true
end,
})

end

--if(minetest.get_modpath("underch")) ~= nil then
--I'll study underch's code a bit more before doing this